package 我的Java学习_算法基础.day_02;

public class _029_找出最长连续递增子序列 {
    public static void main(String[] args) {
        int[] a ={1,9,2,5,7,3,4,6,8,0};
        int[] b = {1,2,3,10,10,10,11,6,5,4,3,2,1};
        f(a);

        f(b);
    }
    private static void f(int[] array){
        int leftIndex=0,rightIndex=0;   //左指引不动，右指引右移
        int maxLength=0,maxIndex=0;     //最大长度，该序列左指引
        for (int i = 0;i<array.length-1;i++){
            if(array[i+1]>array[i]){//满足递增，右指引右移
                rightIndex++;
            }else{
                if((rightIndex-leftIndex)>maxLength){
                    maxLength=rightIndex-leftIndex;
                    maxIndex=leftIndex;
                }
                leftIndex=i+1;
                rightIndex=i+1;
            }
        }
        for(int i = maxIndex;i<=maxLength+maxIndex;i++){
            System.out.print(array[i]+" ");

        }
        System.out.println();
    }
}
